	var ui = {};
	var $content = $('.main');


	function popShow(dom, callback) {
	    popHide();
	    $('.mask').show();
	    dom.show();
	    callback && callback();
	    $('.hide-pop').off('click');
	    $('.hide-pop').click(function() {
	        popHide();
	    });
	}

	function popHide(callback) {
	    $('.mask').hide();
	    $('.pop').hide();
	    callback && callback();
	}

	function popAlert(title, text, callback) {

	    $('.pop-alert .pop-title').html(title);
	    $('.pop-alert .pop-text').html(text);
	    popShow($('.pop-alert'));

	}

	function status(errorCode, flag) {

	    switch (errorCode) {
	        case -200:
	            if (flag) {
	                $content.html('<h2 class="error">错误提示</h2><h3 class="error-content">错误信息：必要参数为空！</h3>');
	            } else {
	                popAlert('错误信息', '必要参数为空！');
	            }
	            break;
	        case -201:
	            if (flag) {
	                $content.html('<h2 class="error">错误提示</h2><h3 class="error-content">错误信息：参数非法！</h3>');
	            } else {
	                popAlert('错误信息', '参数非法！');
	            }
	            break;
	        case -202:
	            if (flag) {
	                $content.html('<h2 class="error">错误提示</h2><h3 class="error-content">错误信息：无首次充值记录！</h3>');
	            } else {
	                popAlert('提示', '无首次充值记录！');
	            }
	            break;
	        case -203:
	            if (flag) {
	                $content.html('<h2 class="error">错误提示</h2><h3 class="error-content">您已领取过该档次奖励，不能重复领取!</h3>');
	            } else {
	                popAlert('提示', '您已领取过该档次奖励，不能重复领取!');
	            }
	            break;
	        case -204:
	            if (flag) {
	                $content.html('<h2 class="error">错误提示</h2><h3 class="error-content">错误信息：无当日充值记录！</h3>');

	            } else {
	                popAlert('提示', '无当日充值记录！');
	            }
	            break;
	        case -205:
	            if (flag) {
	                $content.html('<h2 class="error">错误提示</h2><h3 class="error-content">错误信息：无累计充值记录！</h3>');
	            } else {
	                popAlert('提示', '无累计充值记录！');
	            }
	            break;
	        case -206:
	            if (flag) {
	                $content.html('<h2 class="error">错误提示</h2><h3 class="error-content">错误信息：累计充值时间未开始！</h3>');
	            } else {
	                popAlert('提示', '累计充值时间未开始！');
	            }
	            break;
	        case -207:
	            if (flag) {
	                $content.html('<h2 class="error">错误提示</h2><h3 class="error-content">错误信息：累计充值时间已结束！</h3>');
	            } else {
	                popAlert('提示', '累计充值时间已结束');
	            }
	            break;
	        case -208:
	            if (flag) {
	                $content.html('<h2 class="error">错误提示</h2><h3 class="error-content">错误信息：未找到该服务器的累计充值开始结束时间！</h3>');
	            } else {
	                popAlert('错误信息', '未找到该服务器的累计充值开始结束时间！');
	            }
	            break;
	        case -210:
	            if (flag) {
	                $content.html('<h2 class="error">错误提示</h2><h3 class="error-content">错误信息：充值金额不足！</h3>');
	            } else {
	                popAlert('提示', '充值金额不足！');
	            }
	            break;
	        case -211:
	            if (flag) {
	                $content.html('<h2 class="error">错误提示</h2><h3 class="error-content">错误信息：连接失效！</h3>');
	            } else {
	                popAlert('错误信息', '连接失效！');
	            }
	            break;
	        case -212:
	            if (flag) {
	                $content.html('<h2 class="error">错误提示</h2><h3 class="error-content">错误信息：签名错误！</h3>');
	            } else {
	                popAlert('错误信息', '签名错误！');
	            }
	            break;
	        case -300:
	            if (flag) {
	                $content.html('<h2 class="error">错误提示</h2><h3 class="error-content">错误信息：该奖励已被抢完，请您选择其他奖项！</h3>');
	            } else {
	                popAlert('提示', '该奖励已被抢完，请您选择其他奖项！');
	            }
	            break;
	        case -301:
	            if (flag) {
	                $content.html('<h2 class="error">错误提示</h2><h3 class="error-content">错误信息：未达到领奖资格！</h3>');
	            } else {
	                popAlert('提示', '未达到领奖资格！');
	            }
	            break;
	        case -302:
	            if (flag) {
	                $content.html('<h2 class="error">错误提示</h2><h3 class="error-content">错误信息：您的条件不足以领取首充！</h3>');
	            } else {
	                popAlert('提示', '抱歉，您的条件不足以领取首充！');
	            }
	            break;
	        default:
	            if (flag) {
	                $content.html('<h2 class="error">错误提示</h2><h3 class="error-content">该页面已失效，请重新打开窗口，系统内部异常，异常编码：' + errorCode + '</h3>');
	            } else {
	                popAlert('错误信息', '该页面已失效，请重新打开窗口!<br/>系统内部异常，异常编码：' + errorCode);
	            }

	    }

	}


	function getUrl(key) {
	    var keyArr = location.search.substring(1).split('&');
	    for (var i = 0; i < keyArr.length; i++) {
	        if (key == keyArr[i].split('=')[0]) {
	            return keyArr[i].split('=')[1];
	        }
	    }
	    return '';
	}


	// ui.popShow = popShow;
	// ui.popHide = popHide;
	ui.status = status;



	(function(win, factory) {
	    if ('function' === typeof define && define.amd) {
	        define(function() {
	            return factory();
	        });
	    } else {
	        factory(win);
	    }
	}(window, function(win) {

	    /*
	     * author:gtShen
	     * QQ:903050269
	     * email:sgt_ah@163.com
	     * version:0.5
	     * license:MIT
	     */

	    var Method = {

	        getClass: function(className) {

	            var elements = [];
	            var allElement;
	            var pattern = new RegExp('\\s*' + className + '\\s*');

	            if (document.getElementsByClassName) {
	                return document.getElementsByClassName(className);
	            }

	            if (document.querySelector) {
	                return document.querySelector(className);
	            } else {

	                allElement = document.getElementsByTagName('*');

	                for (var i in allElement) {
	                    if (pattern.test(allElement[i].className)) {
	                        elements.push(allElement[i]);
	                    }
	                }

	                return elements;
	            }

	        },
	        getPos: function(obj) {

	            var offsetLeft = obj.offsetLeft;
	            var offsetTop = obj.offsetTop;
	            var offsetWidth = obj.offsetWidth;
	            var offsetHeight = obj.offsetHeight;
	            var parentElement = obj.offsetParent;

	            while (offsetLeft += parentElement.offsetLeft, offsetTop += parentElement.offsetTop, parentElement = parentElement.offsetParent) {;
	            }
	            return {
	                'left': offsetLeft,
	                'top': offsetTop,
	                'width': offsetWidth,
	                'height': offsetHeight
	            };
	        },
	        removeTips: function(className) {
	            var element = document.getElementById(className);
	            if (element && element.parentNode && element.tagName != 'BODY') {
	                element.parentNode.removeChild(element);
	            }
	        },

	        core: function(img, box, pos, params) {

	            var width = img.width || img.offsetWidth;
	            var height = img.height || img.offsetHeight;
	            var left = pos.left;
	            var top = pos.top;
	            var tw = pos.width;
	            var th = pos.height;
	            var ch = document.documentElement.clientHeight || document.body.clientHeight;
	            var cw = document.documentElement.clientWidth || document.body.clientWidth;

	            if (width + left > cw) {
	                box.style.left = left - width + tw + 'px';
	            }


	            if (ch - (th + top) < height) {
	                box.style.top = top - height + 'px';
	            }

	            box.innerHTML = '';
	            box.appendChild(img);

	            if (!params.loading) {
	                document.body.appendChild(box);
	            }
	        }

	    };

	    function tooltip(params) {



	        var params = params || {};
	        var rel = params.rel || 'rel';
	        var tooltipContentBox = params.tooltipBox || 'tooltip-content-box';
	        var elements = Method.getClass(params.className || 'tooltip');


	        for (var i = 0; i < elements.length; i++) {

	            elements[i].onmouseover = function(e) {

	                var pos = Method.getPos(this);
	                var img = new Image();
	                var source = this.getAttribute(rel);
	                var oDiv = document.createElement('DIV');

	                oDiv.id = tooltipContentBox;
	                oDiv.style.cssText = 'position:absolute;left:' + pos.left + 'px;top:' + (pos.top + pos.height) + 'px;z-index:999999';

	                if (params && params.loading) {

	                    oDiv.innerHTML = '<img src="' + params.loading + '" />';
	                    document.body.appendChild(oDiv);
	                }

	                if (source) {

	                    if (window.attachEvent) {
	                        img.attachEvent('onload', function() {
	                            Method.core(img, oDiv, pos, params);
	                        });
	                    } else {
	                        img.onload = function() {
	                            Method.core(img, oDiv, pos, params);
	                        }
	                    }

	                    img.onerror = img.onabort = function() {
	                        Method.core(img, oDiv, pos, params);
	                    };

	                    img.src = source;

	                }

	            };

	            elements[i].onmouseout = function() {
	                Method.removeTips(tooltipContentBox);
	            }

	        }
	    }

	    if ('function' === typeof define && define.amd) {
	        return tooltip;
	    } else if ('function' === typeof $ && $) {
	        $.tooltip = function(params) {
	            return tooltip(params);
	        }
	    } else {
	        win.tooltip = function(params) {
	            return tooltip(params);
	        }
	    }

	}));